package com.ruoyi.mes.material.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mes.material.mapper.SmesMaterialStockMapper;
import com.ruoyi.mes.material.domain.SmesMaterialStock;
import com.ruoyi.mes.material.service.ISmesMaterialStockService;

/**
 * 原料库存Service业务层处理
 *
 * @author simpsense
 * @date 2020-12-14
 */
@Service
public class SmesMaterialStockServiceImpl implements ISmesMaterialStockService
{
    @Autowired
    private SmesMaterialStockMapper smesMaterialStockMapper;

    /**
     * 查询原料库存
     *
     * @param rowId 原料库存ID
     * @return 原料库存
     */
    @Override
    public SmesMaterialStock selectSmesMaterialStockById(Long rowId)
    {
        return smesMaterialStockMapper.selectSmesMaterialStockById(rowId);
    }

    /**
     * 查询原料库存列表
     *
     * @param smesMaterialStock 原料库存
     * @return 原料库存
     */
    @Override
    public List<SmesMaterialStock> selectSmesMaterialStockList(SmesMaterialStock smesMaterialStock)
    {
        return smesMaterialStockMapper.selectSmesMaterialStockList(smesMaterialStock);
    }

    /**
     * 新增原料库存
     *
     * @param smesMaterialStock 原料库存
     * @return 结果
     */
    @Override
    public int insertSmesMaterialStock(SmesMaterialStock smesMaterialStock)
    {
        smesMaterialStock.setCreateTime(DateUtils.getNowDate());
        smesMaterialStock.setCreateBy(SecurityUtils.getUsername());
        return smesMaterialStockMapper.insertSmesMaterialStock(smesMaterialStock);
    }

    /**
     * 修改原料库存
     *
     * @param smesMaterialStock 原料库存
     * @return 结果
     */
    @Override
    public int updateSmesMaterialStock(SmesMaterialStock smesMaterialStock)
    {
        smesMaterialStock.setUpdateTime(DateUtils.getNowDate());
        smesMaterialStock.setUpdateBy(SecurityUtils.getUsername());
        return smesMaterialStockMapper.updateSmesMaterialStock(smesMaterialStock);
    }

    /**
     * 批量删除原料库存
     *
     * @param rowIds 需要删除的原料库存ID
     * @return 结果
     */
    @Override
    public int deleteSmesMaterialStockByIds(Long[] rowIds)
    {
        return smesMaterialStockMapper.deleteSmesMaterialStockByIds(rowIds);
    }

    /**
     * 删除原料库存信息
     *
     * @param rowId 原料库存ID
     * @return 结果
     */
    @Override
    public int deleteSmesMaterialStockById(Long rowId)
    {
        return smesMaterialStockMapper.deleteSmesMaterialStockById(rowId);
    }
}